﻿using Autofac;
using Autofac.Extras.DynamicProxy;
using ManaMaple.Autofac;
using ManaMaple.DB.Interceptor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ManaMaple.Service.DI
{
    public class ServiceModule : InjectionModule
    {
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);
            builder.RegisterType<OperateInterceptor>(); // 要先注册拦截器
            builder.RegisterType<OperateAsyncInterceptor>(); //注册异步拦截器
            builder.RegisterAssemblyTypes(typeof(ServiceModule).Assembly)
                .InstancePerLifetimeScope()
                .AsImplementedInterfaces()
                .PropertiesAutowired()
                .EnableInterfaceInterceptors() //允许使用拦截器
                .InterceptedBy(typeof(OperateInterceptor));//通过配置拦截;;
        }
    }
}
